package com.zlx.mall.biz.goods.controller;

import com.zlx.mall.basic.web.model.BaseRequest;
import com.zlx.mall.basic.web.model.BaseResponse;
import com.zlx.mall.biz.goods.model.GoodsDetailsResponse;
import com.zlx.mall.biz.goods.model.GoodsListResponse;
import com.zlx.mall.biz.goods.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author xiatian
 * @Date 2025/3/23 星期日 18:57
 * @注释
 */
@RestController
public class GoodsController {
    @Autowired
    private IGoodsService goodsService;

    @PostMapping("/api/goods/list")
    public BaseResponse list(BaseRequest request){
        List<GoodsListResponse> list = goodsService.list(request);
        return BaseResponse.success(list);
    }

    @PostMapping("/api/goods/details")
    public BaseResponse details(BaseRequest request){
        return BaseResponse.success(goodsService.details(request.asValidLong("/id", "商品ID不能为空")));
    }
}
